package com.java110.mall.cart.bmo.businessQuery.impl;

import com.alibaba.fastjson.JSONObject;
import com.java110.dto.housekeeping.HousekeepingResourceDto;
import com.java110.dto.housekeeping.HousekeepingServDto;
import com.java110.intf.goods.IHousekeepingResourceInnerServiceSMO;
import com.java110.intf.goods.IHousekeepingServInnerServiceSMO;
import com.java110.mall.cart.bmo.businessQuery.IBusinessQueryServ;
import com.java110.utils.util.ListUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BusinessQueryServImpl implements IBusinessQueryServ {

    @Autowired
    private IHousekeepingServInnerServiceSMO housekeepingServInnerServiceSMOImpl;

    @Autowired
    private IHousekeepingResourceInnerServiceSMO housekeepingResourceInnerServiceSMOImpl;

    @Override
    public void queryServByName(JSONObject reqJson, String searchValue, String shopId, List<HousekeepingServDto> allHousekeepingServDtos) {

        HousekeepingServDto housekeepingServDto = new HousekeepingServDto();
        housekeepingServDto.setShopId(shopId);
        housekeepingServDto.setPage(1);
        housekeepingServDto.setRow(10);
        housekeepingServDto.setServNameLike(searchValue);
        List<HousekeepingServDto> housekeepingServDtos = housekeepingServInnerServiceSMOImpl.queryHousekeepingServs(housekeepingServDto);
        if (ListUtil.isNull(housekeepingServDtos)) {
            return;
        }
        allHousekeepingServDtos.addAll(housekeepingServDtos);
    }

    @Override
    public void queryServById(JSONObject reqJson, String searchValue, String shopId, List<HousekeepingServDto> allHousekeepingServDtos) {
        HousekeepingServDto housekeepingServDto = new HousekeepingServDto();
        housekeepingServDto.setShopId(shopId);
        housekeepingServDto.setPage(1);
        housekeepingServDto.setRow(10);
        housekeepingServDto.setServId(searchValue);
        List<HousekeepingServDto> housekeepingServDtos = housekeepingServInnerServiceSMOImpl.queryHousekeepingServs(housekeepingServDto);
        if (ListUtil.isNull(housekeepingServDtos)) {
            return;
        }
        allHousekeepingServDtos.addAll(housekeepingServDtos);
    }

    @Override
    public void queryResourceByName(JSONObject reqJson, String searchValue, String shopId, List<HousekeepingResourceDto> allHousekeepingResourceDtos) {

        HousekeepingResourceDto housekeepingResourceDto = new HousekeepingResourceDto();
        housekeepingResourceDto.setResNameLike(searchValue);
        housekeepingResourceDto.setShopId(shopId);
        housekeepingResourceDto.setPage(1);
        housekeepingResourceDto.setRow(10);
        List<HousekeepingResourceDto> housekeepingResourceDtos = housekeepingResourceInnerServiceSMOImpl.queryHousekeepingResources(housekeepingResourceDto);
        if (ListUtil.isNull(housekeepingResourceDtos)) {
            return;
        }
        allHousekeepingResourceDtos.addAll(housekeepingResourceDtos);
    }
}
